package com.pay.ioopos.fragment;

import android.app.Activity;
import android.widget.Toast;

import androidx.fragment.app.Fragment;

import com.pay.ioopos.ErrorListener;
import com.pay.ioopos.activity.AbstractActivity;

public class AbstractErrorFragment extends Fragment implements ErrorListener {
    @Override
    public void onError(String msg) {
        Activity activity = getActivity();
        if (activity instanceof ErrorListener) {
            ((ErrorListener)activity).onError(msg);
        } else if (activity instanceof AbstractActivity) {
            ((AbstractActivity)activity).showToast(msg);
        } else {
            Toast.makeText(getContext(), msg, Toast.LENGTH_LONG);
        }
    }
}
